<template>
	<view class="recommend-goods-container">
		<block v-for="(goods,index) in cart" :key="index">
			<view class="recommend-item">
				<view class="goods-pic-box">
					<image src="../../static/my-images/test.jpg"></image>
				</view>
				<view class="goods-info-box">
					<view style="color: #666;">{{goods.goods_name}}</view>
					<view style="color: #999">{{goods.goods_describe}}</view>
					<view class="goods-type-box">
						<uni-icons type="contact" size="18" ></uni-icons>
						<view class="miaosha-box">秒杀</view>
					</view>
					<view class="purchase-limit-box">限购{{goods.goods_purchase_limit}}</view>
					<view class="price-opera-box">
						<view class="goods-price-box">
							<view class="goods-price"><text style="font-size: 12px;">￥</text>{{goods.goods_price}}</view>
							<view class="origin-price">￥{{goods.goods_origin_price}}</view>
						</view>
						<uni-icons @click="addToCart(goods)" type="cart" size="30" color="#ff0000"></uni-icons>
					</view>
				</view>
			</view>
		</block>
	</view>
</template>

<script>
	import {mapState} from 'vuex'
	export default {
		name:"my-showgoods",
		data() {
			return {
				
			};
		},
		methods:{
			/* 添加到购物车 */
			addToCart(goods){
				console.log(goods);
				uni.$showMsg('已加入购物车')
			}
		},
		computed:{
			...mapState('m_cart',['cart'])
		},
		onload() {
			console.log(this.cart);
		}
	}
</script>

<style lang="scss">
	.recommend-goods-container {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
	}
	.recommend-item {
		font-size: 14px;
		color: gray;
		width: 320rpx;
		margin-top: 20rpx;
		background-color: white;
		border-radius: 10rpx;
		padding: 20rpx 10rpx;
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		.goods-pic-box {
			image {
				height: 320rpx;
				width: 320rpx;
				display: block;
			}
		}
		.goods-info-box {
			margin-top: 10rpx;
			.goods-type-box {
				margin-top: 10rpx;
				font-size: 12px;
				color: #ff0000;
				line-height: 40rpx;
				padding: 0 10rpx;
				background-color: #efefef;
				border-radius: 40rpx;
				display: flex;
				align-items: center;
				display: inline-block;
				.miaosha-box {
					display: inline-block;
				}
			}
			.purchase-limit-box {
				font-size: 12px;
				padding: 10rpx 20rpx;
				border: 1px solid gray;
				border-radius: 10rpx;
				margin-top: 10rpx;
				// display: inline-block;
			}
			.price-opera-box {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 20rpx;
				.goods-price-box {
					display: flex;
					justify-content: flex-start;
					align-items: center;
					.goods-price {
						color: #ff0000;
					}
					.origin-price {
						font-size: 12px;
						text-decoration: line-through;
						margin-left: 10rpx;
					}
				}
			}
		}
	}
</style>